package cn.lingnan.mapper;


import cn.lingnan.annotation.AutoFill;
import cn.lingnan.pojo.dto.PropertyDTO;
import cn.lingnan.pojo.entity.Property;
import cn.lingnan.pojo.vo.TransactionVO;
import cn.lingnan.pojo.vo.UserVO;
import cn.lingnan.utils.OperationType;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface AdminMapper {
    List<TransactionVO> getHouseTransaction(Integer type);

    @Update( "update property.transaction_info set status = 1 where Transaction_id = #{transactionId}" )
    void agreeTransaction(Long transactionId);

    @AutoFill(value= OperationType.INSERT)
    void savePropertyInfo(Property  property);

    @Select( "select * from property.user_info" )
    Page<UserVO> getAllUserInfo();

//    @AutoFill(value= OperationType.UPDATE)
    @Update( "update property.user_info set status = #{status},update_time=now() where user_id = #{userId}" )
    void toggleUserStatus(Long userId, Integer status);

    @Delete(  "delete from property.user_info where user_id = #{userId}" )
    void deleteUser(Long userId);

    @Select( "select * from property.user_info where user_id = #{userId}" )
    UserVO getUserInfoById(Long userId);
}
